package cz.muni.fi.pa165.rentalofconstructionmachinery.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;

/**
 *
 * @author Adam Zmrzlý
 * @version Aventador (20121101)
 *
 * Revision entity
 */
@Entity
public class Revision implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @ManyToOne(optional=false) //Every revision must been related to a machine
    @JoinColumn(name="machine_id")
    private Machine machine;

    @Column(name="dateOfRevision")
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date date;
    
    private String comment;

   
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Machine getMachine() {
        return machine;
    }

    public void setMachine(Machine machine) {
        this.machine = machine;
    }

    public Revision() {
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Revision)) {
            return false;
        }
        Revision other = (Revision) object;
        if (this.id == null || !this.id.equals(other.id)) {
            return false;
        }
        return true;
    }

    public String toString() {
        return "Revision{" + "id=" + id + "machine_id=" + machine.getId() + "date=" + date + "comment=" + comment + '}';
    }
}
